package com.wh1200.mybatis.xmlless.config

import com.wh1200.mybatis.xmlless.replaceSpace
import com.wh1200.xmlless.test.dao.ServerDAO
import com.wh1200.xmlless.test.model.Server
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals


/**
 *
 * Created by 吴昊 on 2018-12-09.
 *
 * @author 吴昊
 * @since 0.0.1
 */
class ServerMappingsTest : BaseResolverTest(
    ServerDAO::class.java
) {

  @Test
  fun resolveJoins() {
    val joins = mappings.selectJoins(
        1,
        includedTableAlias = listOf("parent_id_server", "provider_id_t_server_provider")
    )
    assertEquals(2, joins.size)
    assertEquals(
        "LEFT JOIN server parent_id_server ON id = parentId",
        joins[0].toSql().replaceSpace()
    )
    assertEquals(
        "LEFT JOIN t_server_provider provider_id_t_server_provider ON id = providerId",
        joins[1].toSql().replaceSpace()
    )
  }

}
